package gcxy.train.account.ex.service.impl;

import java.util.Collection;
import java.util.Scanner;

import gcxy.train.account.ex.dao.IAccountDAO;
import gcxy.train.account.ex.dao.impl.collection.AccountDao;
import gcxy.train.account.ex.exception.HasExistException;
import gcxy.train.account.ex.exception.NoExistException;
import gcxy.train.account.ex.model.vo.Account;
import gcxy.train.account.ex.service.IAccountService;

public class AccountServiceImpl implements IAccountService {
	
	IAccountDAO accountdao=new AccountDao();
	@Override
	public Collection<Account> getAllAccounts() {
		// TODO Auto-generated method stub
		return accountdao.findAccounts();
	}

	@Override
	public void addAccount(Account account) throws IllegalArgumentException, HasExistException, Exception {
		// TODO Auto-generated method stub
		accountdao.insertAccount(account);
	}
	
	

	@Override
	public Account getOneAccount(String no){
		// TODO Auto-generated method stub
		return accountdao.findByAccountNo(no);
	}

	@Override
	public void alterAccount(Account account)   throws NoExistException,IllegalArgumentException{
		// TODO Auto-generated method stub
		accountdao.updateAccount(account);
		
	}

	@Override
	public boolean delectAccount(String account) {
		// TODO Auto-generated method stub
		return accountdao.deletAccount(accountdao.findByAccountName(account));
	}
}


